Hi Tom,
I implemented I2C via bit-bang on my new breakout board, and am trying to optimize its speed.
Using the code that you provided on a previous thread (related to SPI, but should apply to I2C) I could not get the direct FPGA writes working. The commented-out code does not work, but the normal function calls do work. scl_bit is 30.
for (;;) {
//FPGA(BIT_SET+(scl_bit>>3)) = 1<<(scl_bit&7);
//FPGA(BIT_CLR+(scl_bit>>3)) = 1<<(scl_bit&7);
SetBit(scl_bit);
ClearBit(scl_bit);
}
Running this gives about 750ns between edges (1.5us period). With the FPGA direct writes, the output stays high.
The reason I would like to use direct writes is that I have multiple bits to manipulate since I have 4 I2C buses (and the bit numbers are contiguous). Since I/O is so slow, it is important to get the most possible work done with each I/O, so setting multiple bits at once is useful.
Using a Kflop with Kmotion version 432.
Regards,
SJH